<?php

namespace App\Jobs\Company;

use App\Models\Company;
use Illuminate\Bus\Queueable;
use App\Models\System\Setting;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * 创建默认设置
 *
 * Date: 2018/6/15
 * @author George
 * @package App\Jobs\Company
 */
class CreateSetting implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

	/**
	 * @var Company
	 * Date: 2018/6/4
	 * @author George
	 */
    protected $company;

	/**
	 * CreateSetting constructor.
	 * @param Company $company
	 */
    public function __construct(Company $company)
    {
        $this->company = $company;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
		try {
			$setting = [
				'company_id' => $this->company->id,
				'register' => [
					'stature' => 'required',
					'weight' => 'required',
					'education' => 'required',
					'address' => 'required',
					'marital' => 'required',
					'urgency_name' => 'required',
					'urgency_mobile' => 'required',
					'urgency_relation' => 'required',
					'trade' => 'required',
					'skill' => 'required',
					'channel' => 'required',
				],
				'attendance' => [
					'first' => 5,
					'second' => 4,
					'third' => 3,
					'last' => -9,
					'tardy' => -2,
					'early' => -2,
					'nsignout' => -1,
					'absenteeism' => -10,
				],
				'created_at' => date('Y-m-d H:i:s'),
				'updated_at' => date('Y-m-d H:i:s')
			];
			Setting::create($setting);
		} catch (Exception $exception) {
			Log::error($exception);
		}
    }
}
